package com.tom.chain_of_responsibility.v1.factory;

import com.tom.chain_of_responsibility.model.req.UserSearchReq;
import com.tom.chain_of_responsibility.v1.IRequestHandler;
import com.tom.chain_of_responsibility.v1.impl.OneRequestHandler;
import com.tom.chain_of_responsibility.v1.impl.ThreeRequestHandler;
import com.tom.chain_of_responsibility.v1.impl.TwoRequestHandler;

/**
 * 请求处理工厂
 *
 * @author zx
 * @date 2024-10-10 20:52
 */
public class RequestHandlerFactory {
    private IRequestHandler first;

    public RequestHandlerFactory(){
        OneRequestHandler oneRequestHandler = new OneRequestHandler();
        TwoRequestHandler twoRequestHandler = new TwoRequestHandler();
        ThreeRequestHandler threeRequestHandler = new ThreeRequestHandler();

        oneRequestHandler.setNext(twoRequestHandler);
        twoRequestHandler.setNext(threeRequestHandler);

        first = oneRequestHandler;
    }

    public Boolean executeHandler(UserSearchReq userSearchReq) {
        return first.handleRequest(userSearchReq);
    }


}
